class Solution {
public:
    int findSmallestInteger(vector<int>& nums, int value) {
        
        vector<int> vecFlg(value+1);
        for(int i=0;i<nums.size();++i){
            int remainder=(nums[i]%value+value)%value;
            ++vecFlg[remainder];
        }

        int mex=0;
        while(true){
            int remainder=mex%value;
            if(vecFlg[remainder]>0){
                --vecFlg[remainder];
                ++mex;
            }
            else{
                break;
            }
        }

        return mex;
    }
};
